//
//  Chat.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/10/12.
//

import Foundation

enum EnumSender:Codable {
  case Passenger
  case Driver
}

struct Chat: Codable, Identifiable {
  var id = UUID()
  let desc: String
  let sender:EnumSender
  let time:String

  func senderIcon() -> String {
    if self.sender == .Driver {
      return "driver_avatar"
    } else {
      return "passenger_avatar"
    }
  }

  func senderName() -> String {
    if self.sender == .Driver {
      return "司机"
    } else {
      return "我"
    }
  }
}

extension Chat {
  static let all:[Chat] = [
    hello
  ]

  static let hello = Chat(desc:"你好，感谢您选择我的服务。", sender: .Driver, time: Date().toDisplayString("MM:dd"))
}
